home *** CD-ROM | disk | FTP | other *** search
/ Programming a Multiplayer FPS in DirectX / Programming a Multiplayer FPS in DirectX (Companion CD).iso / Source / Chapter 11 / Engine / RenderCache.h < prev    next >
Encoding:
C/C++ Source or Header  |  2004-10-01  |  1.4 KB  |  40 lines

  1. //-----------------------------------------------------------------------------
  2. // Manages the rendering of indexed faces from a set of vertices.
  3. //
  4. // Programming a Multiplayer First Person Shooter in DirectX
  5. // Copyright (c) 2004 Vaughan Young
  6. //-----------------------------------------------------------------------------
  7. #ifndef RENDER_CACHE_H
  8. #define RENDER_CACHE_H
  9.  
  10. //-----------------------------------------------------------------------------
  11. // Render Cache Class
  12. //-----------------------------------------------------------------------------
  13. class RenderCache
  14. {
  15. public:
  16.     RenderCache( IDirect3DDevice9 *device, Material *material );
  17.     virtual ~RenderCache();
  18.  
  19.     void AddFace();
  20.     void Prepare( unsigned long totalVertices );
  21.  
  22.     void Begin();
  23.     void RenderFace( unsigned short vertex0, unsigned short vertex1, unsigned short vertex2 );
  24.     void End();
  25.  
  26.     Material *GetMaterial();
  27.  
  28. private:
  29.     IDirect3DDevice9 *m_device; // Pointer to a Direct3D device.
  30.     Material *m_material; // Pointer to the material used by this render cache.
  31.  
  32.     IDirect3DIndexBuffer9 *m_indexBuffer; // Index buffer pointing to the vertices to render.
  33.     unsigned short *m_indexPointer; // Pointer for accessing the index buffer.
  34.     unsigned long m_totalIndices; // Total number of indices this render cache can handle.
  35.     unsigned long m_faces; // Total number of faces to be rendered.
  36.  
  37.     unsigned long m_totalVertices; // Total number of vertices.
  38. };
  39.  
  40. #endif